package router

import (
	"jnjword/service"

	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"

	// _ "JNJWROD/docs" // 确认模块名与go.mod一致
	_ "jnjword/docs"
)

func Router() *gin.Engine {

	r := gin.Default()
	// 定义API路由

	// 启用Swagger UI
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	// 创建一个用户相关的路由组
	userGroup := r.Group("/user")
	{
		userGroup.GET("/getUserList", service.GetUserList)
		userGroup.POST("/createUser", service.CreateUser)
		userGroup.POST("/deleteUser", service.DeleteUser)
		userGroup.GET("/findUser", service.FindUserByName)
		userGroup.POST("/updateUser", service.UpdateUser)
		userGroup.POST("/Login", service.Login)

	}
	// 创建一个单词相关的路由组
	wordGroup := r.Group("/word")
	{
		wordGroup.GET("/getUserWordList", service.GetUserWordList)
		wordGroup.POST("/createUserWord", service.CreateUserWord)
		wordGroup.POST("/deleteUserWord", service.DeleteUserWord)
		wordGroup.POST("/updateUserWord", service.UpdateUserWord)
		wordGroup.POST("/updateUserWordSelf", service.UpdateUserWordSelf)
	}
	return r
}
